import 'testPage/index.dart';
import 'package:flutter/material.dart';
import 'itemPage/index.dart';
import 'userInfoPage/index.dart';
import 'package:bruno/bruno.dart';

// 分页组件
class IndexPage extends StatefulWidget {
  const IndexPage({super.key});

  @override
  State<IndexPage> createState() => _IndexPageState();
}

class _IndexPageState extends State<IndexPage> {
  final List<BrnBottomTabBarItem> bootomTabs = [
    const BrnBottomTabBarItem(
        icon: Icon(Icons.done_all, color: Colors.red),
        title: Text('打卡'),
        backgroundColor: Colors.black),
    const BrnBottomTabBarItem(
        icon: Icon(Icons.manage_accounts, color: Colors.pink),
        title: Text('用户'),
        backgroundColor: Colors.black),
    const BrnBottomTabBarItem(
        icon: Icon(Icons.build, color: Colors.pink),
        title: Text('测试页面'),
        backgroundColor: Colors.black)
  ];

  final List<Widget> tabBodies = [
    const ItemPage(),
    const UserInfoPage(),
    const DemoPage()
  ];

  int indexNum = 0;
  var pageView;

  // 初始化
  @override
  void initState() {
    pageView = tabBodies[indexNum];
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      // backgroundColor: Colors.red,
      bottomNavigationBar: BrnBottomTabBar(
        items: bootomTabs,
        currentIndex: indexNum,
        isAnimation: true,
        onTap: (index) {
          setState(() {
            indexNum = index;
            pageView = tabBodies[indexNum];
          });
        },
      ),
      body: tabBodies[indexNum],
    );
  }
}
